/******************************************************************************
** @file	test_cm_dblitemanager.cpp
** @author  Joel Chuca
**
** @date	Sep 01, 2010
**
** @desc	This testSuite tests the creating of database and tables.
*			
******************************************************************************/

#include "unit--.h"
#include <string>
#include <iostream>
#include <vector>
#include <cm_dblitemanager.h>
#include <cm_resultcollection.h>
#include "bc_utils.h"

using namespace unit_minus;
using namespace std;

testSuite(BridgedComunicator);

testCase(fillProcessDifferences, BridgedComunicator)
{
	int idComputer = 1;
    CM_ResultCollection resultCollection;

    CM_DBLiteManager dbManager;
	//dbManager.initialize();

	CM_ResultCollection current;
	CM_ResultCollection beforeCurrent;
	dbManager.getLastCollection(idComputer, current);
	dbManager.getBeforeLastCollection(idComputer, beforeCurrent);

	WMI_Result<WMI_Process> differencesProcess;

    bc_utils::fillDifferences(current.getProcesses(), beforeCurrent.getProcesses(), differencesProcess);
   	vector<WMI_Process*>& processVec = differencesProcess.getObjects();

	wcout << L"-------- differences processeses: " << endl;
    for(vector<WMI_Process*>::const_iterator it = processVec.begin(); it != processVec.end(); it++ )
    {
        wcout << L"caption: " << (*it)->getCaption() << endl;        
    }
}

testCase(fillShareDifferences, BridgedComunicator)
{
	int idComputer = 1;
    CM_ResultCollection resultCollection;

    CM_DBLiteManager dbManager;
	//dbManager.initialize();

	CM_ResultCollection current;
	CM_ResultCollection beforeCurrent;
	dbManager.getLastCollection(idComputer, current);
	dbManager.getBeforeLastCollection(idComputer, beforeCurrent);

	WMI_Result<WMI_Share> differences;

   	bc_utils::fillDifferences(current.getShares(), beforeCurrent.getShares(), differences);
   	vector<WMI_Share*>& processVec = differences.getObjects();

	wcout << L"-------- differences shares: " << endl;
    for(vector<WMI_Share*>::const_iterator it = processVec.begin(); it != processVec.end(); it++ )
    {
        wcout << L"caption: " << (*it)->getCaption() << endl;        
    }
}

testCase(fillRegistryDifferences, BridgedComunicator)
{
	int idComputer = 1;
    CM_ResultCollection resultCollection;

    CM_DBLiteManager dbManager;
	//dbManager.initialize();

	CM_ResultCollection current;
	CM_ResultCollection beforeCurrent;
	dbManager.getLastCollection(idComputer, current);
	dbManager.getBeforeLastCollection(idComputer, beforeCurrent);

	WMI_Result<WMI_Registry> differences;

    bc_utils::fillRegistryDifferences(current.getRegistries(), beforeCurrent.getRegistries(), differences);
    WMI_Registry* diference = differences.getParentRegistry();
    wcout << L"Name: " << diference->getName() << endl;	
}